package com.loyal.loyalerp.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.loyal.loyalerp.model.GyUser;
import com.loyal.loyalerp.model.vo.UserNameAndCode;

@Mapper
public interface GyUserMapper {

	int deleteByPrimaryKey(Integer id);

	int insert(GyUser record);

	int insertSelective(GyUser record);

	GyUser selectByPrimaryKey(Integer id);

	int updateByPrimaryKeySelective(GyUser record);

	int updateByPrimaryKey(GyUser record);

	@Delete("delete from gy_user where companyId=#{id}")
	int deleteByCompanyId(Integer id);

	// 查询所有的用户
	List<GyUser> selectAllEmploy();

	// 根据用户编码查询
	public List<GyUser> selectUserByUsercode(String usercode);

	// 根据用户姓名查询
	public List<GyUser> selectUserByUserName(String usercode);

	// 查询所有公司名称
	public List<String> selectAllCompany();

	// 判断用户编码是否已经存在
	public int selectUserHasExist(String usercode);

	@Select("select * from gy_user where companyId=#{id}")
	List<GyUser> selectByCompanyId(Integer id);

	// 根據用戶主鍵查詢用戶編碼
	public String selectUsercodeByPrimaryKey(int key);

	// 根据公司名称查询公司Id
	public int selectCompanyIdByName(String companyName);

	// 根据用户名查询用户ID
	public int selectUserIDByusername(String username);

	public List<UserNameAndCode> selectAllUserCodeAndName();

	public GyUser selectPersonByCode(String code);

	public String selectCompanyNameById(int id);

	// 根据用户编码查询用户ID
	public int selectUserIDByUserCode(String usercode);

	// 查看所有未注册的员工
	public List<UserNameAndCode> selectAllUnRegistPerson();

	@Select("select * from gy_user where mobile=#{mobile}")
	List<GyUser> getUserByMobile(String mobile);
}